package;


import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.text.FlxText;
import flixel.ui.FlxButton;
import flixel.util.FlxMath;
import flixel.util.FlxColor;
import flixel.addons.text.FlxTypeText;
import flixel.util.FlxRandom;

/**
 * A FlxState which can be used for the game's menu.
 */
class RelojMienteState extends PreguntaState
{
	
	private var timeLeft:Float;
	private var timeSpeed:Float;
	
	/**
	 * Function that is called up when to state is created to set it up. 
	 */
	
	override public function create():Void
	{
		super.create();
		timeLeft = FlxRandom.floatRanged(2, 4);
		timeSpeed = FlxRandom.floatRanged(0.5, 1.5);
		estado = "esperando2";
	}
	
	override function update():Void
	{
		super.update();		
		switch(estado)
		{
			case "esperando2":
				var modifier:Float = 1;
				timeLeft -= FlxG.elapsed;
				if (timeLeft < 0)
				{
					timeSpeed -= FlxG.elapsed;
					modifier = 5;
					if (timeSpeed < 0)
					{
						timeLeft = FlxRandom.floatRanged(2, 4);
						timeSpeed = FlxRandom.floatRanged(0.5,1.5);
					}
				}
				_reloj -= FlxG.elapsed * modifier;
				_relojTexto.text = Std.string(Std.int(_reloj));
				if (_reloj < 1 || (player1.getInput() != -1 && player2.getInput() != -1 && player3.getInput() != -1 && player4.getInput() != -1))
				{
					_pregunta.start(0);
					estado = "mostrando";
					channel.stop();
					channel = sound.play(30000);
					textoAzul.visible = false;
					textoRojo.visible = false;
					textoVerde.visible = false;
					textoAmarillo.visible = false;
				}
				
		}
	}

}